<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<link  href="<%=request.getContextPath() %>/assets/bootstrap/css/bootstrap.css" 	rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=request.getContextPath() %>/assets/jquery-1.9.1.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/assets/bootstrap/js/bootstrap.js"></script>

<body>
<table class="table" align="center" width="800" >
   <caption ><h1 align="center">购物车</h1></caption>
   <thead>
      <tr>
         <th>编号</th>
         <th>产品</th>
         <th>单价</th>
         <th>数量</th>
         <td>共计</td>
         <td></td>
      </tr>
   </thead>
   
   		
   <tbody>
   <c:forEach items="${list }" var="cart">
   <tr>
   		<td>${cart.id }</td>
   		<td>${cart.app.appname }</td>
   		<td>${cart.app.price }元/个</td>
   		<td>${cart.buyNum }个</td>
   		<td>${cart.app.price*cart.buyNum }元</td>
   		<td><button class="btn btn-danger" onclick="todel('${cart.id }')">取消</button></td>
   </tr>

   </c:forEach>
   </tbody>
      <tr>
   			<td colspan="11" align="center"><button style="width: 200px"   class="btn btn-info" onclick="toadd()">提交</button></td>
   </tr>
 
</table>

<script type="text/javascript">
function toadd(){
	var username='${userinfo}';
	//alert(username)
	if(username!=null && username!=''){
		alert("确认提交")
	 	$.ajax({
			url:"toadd.action",
			type:"post"
		}) 
	}else{
		alert("请先登录")
		location.href="monliao/login.jsp";
	}

}
function todel(id){
	$.ajax({
		url:"del.action",
		type:"post",
		data:{id:id},
		success:function(){
			location.reload();
		}
	}) 
}
</script>
</body>
</html>